<?php 
	class UserAction extends CommonAction{
		public function index(){
			$this->user=M('user')->select();
			$ip='125.83.11.28';
			$json=file_get_contents('http://ip.taobao.com/service/getIpInfo.php?ip='.$ip);
			$arr=json_decode($json);
			$this->address=$arr->data->country.$arr->data->city.'('.$arr->data->isp.')';
			$this->display();
		}

		//改密/该用户名
		public function update(){
			$this->id=$_GET['id'];
			$this->display();
		}

		//表单处理
		public function upHandle(){
			$data=array(
				'id'=>(int)$_POST['id'],
				'username'=>$_POST['username'],
				'password'=>md5($_POST['pwd']),
				);
			if(M('user')->save($data)){
				$this->success('修改成功!',U(GROUP_NAME.'/User/index'));
			}else $this->error('修改失败!');
		}
	}